package net.kazed.nextaction.database.serialize;

import java.util.HashMap;
import java.util.Map;

import android.content.ContentResolver;
import android.database.CharArrayBuffer;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Bundle;

/**
 * Cursor to query a list of objects.
 * @author Koert Zeilstra
 */
public abstract class AbstractListCursor implements Cursor {

    private int size = 0;
    private int columnCount  = 0;
    private int position = 0;
    private Map<String, Integer> columnNameMapping = new HashMap<String, Integer>();
    
    /**
     * Constructor.
     */
    protected AbstractListCursor() {
    }

    /**
     * @param size Size of list.
     */
    protected void setListSize(int size) {
        this.size = size;
    }
    
    /**
     * @param columnCount Number of columns.
     */
    protected void setNumberOfColumns(int numberOfColumns) {
        this.columnCount = numberOfColumns;
    }
    
    /**
     * Add mapping from column name to column index.
     * @param columnName Column name.
     * @param columnIndex Column index.
     */
    protected void addColumnNameMapping(String columnName, int columnIndex) {
        columnNameMapping.put(columnName, columnIndex);
    }

    
    public void close() {
    }

    public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
    }

    public void deactivate() {
    }

    public byte[] getBlob(int columnIndex) {
        return null;
    }

    public int getColumnCount() {
        return columnCount;
    }

    public int getColumnIndex(String columnName) {
        Integer index = columnNameMapping.get(columnName);
        if (index == null) {
            return 0;
        } else {
            return index.intValue();
        }
    }

    public int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException {
        return 0;
    }

    public String getColumnName(int columnIndex) {
        return null;
    }

    public String[] getColumnNames() {
        return null;
    }

    public int getCount() {
        return size;
    }

    public double getDouble(int columnIndex) {
        return 0;
    }

    public Bundle getExtras() {
        return null;
    }

    public float getFloat(int columnIndex) {
        return 0;
    }

    public int getInt(int columnIndex) {
        return 0;
    }

    public long getLong(int columnIndex) {
        return 0;
    }

    public int getPosition() {
        return position;
    }

    public short getShort(int columnIndex) {
        return 0;
    }

    public String getString(int columnIndex) {
        return null;
    }

    public boolean getWantsAllOnMoveCalls() {
        return false;
    }

    public boolean isAfterLast() {
        return position >= size;
    }

    public boolean isBeforeFirst() {
        return position < 0;
    }

    public boolean isClosed() {
        return false;
    }

    public boolean isFirst() {
        return position == 0;
    }

    public boolean isLast() {
        return false;
    }

    public boolean isNull(int columnIndex) {
        return false;
    }

    public boolean move(int offset) {
        return false;
    }

    public boolean moveToFirst() {
        position = 0;
        return size > 0;
    }

    public boolean moveToLast() {
        position = size - 1;
        return size > 0;
    }

    public boolean moveToNext() {
        boolean result = false;
        if (position < size) {
            position++;
            result = true;
        }
        return result;
    }

    public boolean moveToPosition(int position) {
        boolean result = false;
        if (position >= 0 && position < size) {
            this.position = position;
            result = true;
        }
        return result;
    }

    public boolean moveToPrevious() {
        boolean result = false;
        if (position >= 0) {
            position--;
            result = true;
        }
        return result;
    }

    public void registerContentObserver(ContentObserver observer) {
    }

    public void registerDataSetObserver(DataSetObserver observer) {
    }

    public boolean requery() {
        return false;
    }

    public Bundle respond(Bundle extras) {
        return null;
    }

    public void setNotificationUri(ContentResolver cr, Uri uri) {
    }

    public void unregisterContentObserver(ContentObserver observer) {
    }

    public void unregisterDataSetObserver(DataSetObserver observer) {
    }

}
